<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<html>
<head>
<title></title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/css/css.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/jquery-treetable/css/jquery.treetable.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/static/jquery-treetable/css/jquery.treetable.theme.default.css">
<style>
#table th, #table td {
	font-size: 14px;
	padding: 8px;
}
</style>
</head>
<body>

	<c:if test="${not empty msg}">
		<div class="message">${msg}</div>
	</c:if>

	<table id="table">
		<thead>
			<tr>
				<th>名称</th>
				<th>类型</th>
				<th>URL路径</th>
				<th>权限字符串</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${resourceList}" var="resource">
				<tr data-tt-id='${resource.resource_id}'
					<c:if test="${resource.parent_id != 0}">data-tt-parent-id='${resource.parent_id}'</c:if>>
					<td>${resource.resource_name}</td>
					<td>${resource.resource_type}</td>
					<td>${resource.resource_request_uri}</td>
					<td>${resource.permissions_code}</td>
					<td><shiro:hasPermission name="resource:create">
							<c:if test="${resource.resource_type eq 'menu'}">
								<a
									href="${pageContext.request.contextPath}/resource/${resource.resource_id}/appendChild">添加子节点</a>
							</c:if>
						</shiro:hasPermission> <shiro:hasPermission name="resource:update">
							<a
								href="${pageContext.request.contextPath}/resource/${resource.resource_id}/update">修改</a>
						</shiro:hasPermission> <c:if test="${resource.parent_id != 0}">

							<shiro:hasPermission name="resource:delete">
								<a class="deleteBtn" href="#" data-id="${resource.resource_id}">删除</a>
							</shiro:hasPermission>
						</c:if></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>

	<script
		src="${pageContext.request.contextPath}/static/js/common/jquery-1.11.0.min.js"></script>
	<script
		src="${pageContext.request.contextPath}/static/jquery-treetable/jquery.treetable.js"></script>
	<script>
		$(function() {
			$("#table").treetable({
				expandable : true
			}).treetable("expandNode", 1);
			$(".deleteBtn")
					.click(
							function() {
								if (confirm("确认删除吗?")) {
									location.href = "${pageContext.request.contextPath}/resource/"
											+ $(this).data("id") + "/delete";
								}
							});
		});
	</script>
</body>
</html>